package repo

import (
	"rc/repo/jsonrepo"
	"rc/repo/model"
)

var r Repo

type Repo interface {
	GetNodeGroups(name string) ([]model.NodeGroup, error)
	GetFirstNodeGroup(name string) (model.NodeGroup, error)
	GetNodes(name string, groupName string) ([]model.Node, error)
	GetFirstNode(name string, groupName string) (model.Node, error)
	GetNodesWithGroupName(name string, groupName string) ([]model.Node, []string, error)
}

func InitRepo(repoPath string) error {
	var err error
	r, err = jsonrepo.InitRepo(repoPath)
	if err != nil {
		r = nil
	}

	return err
}

func GetRepo() Repo {
	return r
}
